package com.varian.system.controller;

import com.varian.log.annotation.ApiLog;
import com.varian.service.annotation.Resubmit;
import com.varian.service.web.BaseController;
import com.varian.system.dto.UserNoticeListDTO;
import com.varian.system.service.IUserNoticeService;
import com.varian.system.vo.UserNoticeVO;
import com.varian.tool.result.IR;
import com.varian.tool.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ben
 * @since 2024/9/5
 */
@Resubmit
@Tag(name = "用户通知控制层")
@RestController
@RequiredArgsConstructor
@RequestMapping("/user-notice")
public class UserNoticeController extends BaseController<IUserNoticeService> {

    @ApiLog
    @Operation(summary = "获取当前用户通知")
    @GetMapping("list")
    public R<List<UserNoticeVO>> list(@Validated UserNoticeListDTO dto){
        return R.data(baseService.list(dto));
    }

    @ApiLog
    @Operation(summary = "获取用户通知")
    @GetMapping("{noticeId:\\d+}")
    public R<UserNoticeVO> detail(@PathVariable("noticeId") Long noticeId){
        return R.data(baseService.detail(noticeId));
    }

    @ApiLog
    @Operation(summary = "用户通知已读")
    @PutMapping("read/{noticeId:\\d+}")
    public IR read(@PathVariable("noticeId") Long noticeId){
        return R.status(baseService.read(noticeId));
    }

    @ApiLog
    @Operation(summary = "全部已读")
    @PutMapping("read-all")
    public IR readAll(){
        return R.status(baseService.readAll());
    }
}
